<%@page import="com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Model.*"%>
<%@page import="POJO.*"%>
<% 
	ArrayList<OrderPOJO> order;
	String id = (String)request.getParameter("key"); 
	if(id != null)
	{
		
		order = OrderModel.TimKiem(id);
	}
	else
	{
		order =   OrderModel.DanhSachDonHang();
	}
%>

<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<div id="content">

	<!--  start page-heading -->
	<div id="page-heading">
		<h1>View Orders</h1>
	</div>
	<!-- end page-heading -->
	
	

	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tr>
		<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		<th class="topleft"></th>
		<td id="tbl-border-top">&nbsp;</td>
		<th class="topright"></th>
		<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id="content-table-inner">
		
			<!--  start table-content  -->
			 <%if(session.getAttribute("doSuscess")!= null ) { %>
			 <!--  start message-green -->
					<div id="message-green">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="green-left"><%= (String)session.getAttribute("doSuscess")%>.</td>
						<td class="green-right"><a class="close-green"><img src="images/table/icon_close_green.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
			<!--  end message-green -->
			<%
				session.removeAttribute("doSuscess");
			}
			 else if(session.getAttribute("doError")!= null)
			 {
			%>
				<!--  start message-red -->
					<div id="message-red">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">				
					<tr>
						<td class="red-left">Error. Please try again.</td>
						<td class="red-right"><a class="close-red"><img src="images/table/icon_close_red.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
				<!--  end message-red -->
			<%
				session.removeAttribute("doError");
			 }	
			 %> 
			<div id="table-content">
		 
				<!--  start product-table ..................................................................................... -->
			
				<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
				<tr>
					<th class="table-header-repeat line-left minwidth-1"><a href="">ID</a>	</th>
					<th class="table-header-repeat line-left minwidth-1"><a href="">Date</a></th>
					<th class="table-header-repeat line-left minwidth-1"><a href="">Customer</a></th>
					<th class="table-header-repeat line-left"><a href="">Total</a></th>
				</tr>
				
				<%
					OrderPOJO itemOrder;
					for(int i=0; i< order.size(); i++ )
					{		
						itemOrder =  order.get(i);
				%>
				
				
				<tr <% if(i%2 ==0 ) out.write("class='alternate-row'"); %>>
					<td><a href="?id=<%= itemOrder.GetID() %>"><%= itemOrder.GetID()%></a></td>
					<td><a href="?id=<%= itemOrder.GetID() %>"><%= itemOrder.GetDate()%></a></td>
					<td><a href="?id=<%= itemOrder.GetID() %>"><%= CustomerModel.selectCustomerByID(Integer.toString(itemOrder.GetCustomerID())).GetName()%></a></td>
					<td><a href="?id=<%= itemOrder.GetID() %>"><%= itemOrder.GetTotal()%></a></td>
					
				</tr>
				
				<%
					}
				%>
				
				</table>
				<!--  end product-table................................... --> 
			
			</div>
			<!--  end content-table  -->
		
			
			<div class="clear"></div>
		 
		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->